perm filename FORMAT.TEX[TEX,ALS] blob sn#762570 filedate 1984-07-23 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00004 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	\beginchapter Appendix E. Example Formats
C00010 00003	\def\today{\ifcase\month\or
C00013 00004	\def\up#1{\leavevmode \raise.16ex\hbox{#1}}
C00019 ENDMK
C⊗;
\beginchapter Appendix E. Example Formats

Although the plain \TeX\ format of Appendix B is oriented to technical
reports, it can readily be adapted to quite different applications. Examples of
three such adaptations are provided in this appendix: (1)~a~format for
business letters; (2)~a~format for concert programs; (3)~the~format used
to typeset this book.

Let's consider ↑{business letters} first. Suppose that you want \TeX\ to
format your ↑{correspondence}, and that you have $n$~letters to send. ↑↑{mail}
If your computer system contains a file ↑|letterformat.tex| like the one
described later in this appendix, it's easy to do the job by applying \TeX\ to
a file that looks like this:
\begindisplay
\<optional magnification>\cr
↑|\input|| letterformat|\cr
\<business letter$_1$>\cr
\noalign{\vskip-1pt}
\qquad\vdots\cr
\<business letter$_n$>\cr
↑|\end|\cr
\enddisplay
Here each of the $n$ business letters has the form
\begindisplay
\<letterhead>\cr
↑|\address|\cr
\<one or more lines of address>\cr
↑|\body|\cr
\<one or more paragraphs of text>\cr
↑|\closing|\cr
\<one or more lines for salutation and signature>\cr
\<optional annotations>\cr
\<optional postscripts>\cr
↑|\endletter|\cr
↑|\makelabel|| % omit this if you don't want an address label|\cr
\enddisplay
The \<letterhead> at the beginning of this construction is usually a
control sequence like |\rjdletterhead| for letters by R.~J.~D.; each
letter writer can have a personalized letterhead that is stored with the
|letterformat| macros. The \<optional annotations> at the end are any number
of one-line notes preceded by `↑|\annotations|'; the \<optional postscripts>
are any number of paragraphs preceded by `↑|\ps|'. When \TeX\ is processing the
|\address| and the |\closing| and the optional |\annotations|, it produces
output line-for-line just as the lines appear in the input file; but when
\TeX\ is processing the |\body| of the letter and the optional |\ps|, it
chooses line breaks and justifies lines as it normally does when
typesetting paragraphs in books.

A complete example, together with the resulting output, appears on the
next two pages. This example starts with `↑|\magnification||=|↑|\magstep||1|'
because the letter is rather short. Magnification is usually omitted if the
letters are long-winded; `|\magnification=|↑|\magstephalf|' is
appropriate when they are medium-size. The same magnification applies to
all~$n$ letters, so you must run \TeX\ more than once if you want more than
one magnification.

\eject
\begingroup \obeylines
|\magnification=\magstep1|
|\input letterformat|
\bigskip
|\rjdletterhead % (see the output on the next page)|
\bigskip
|\address|
|Prof.~Brian~K. Reid|↑↑{Reid}
|Department of Electrical Engineering|
|Stanford University|
|Stanford, CA 94305|
\bigskip
|\body|
|Dear Prof.~Reid:|
\bigskip
|I understand that you are having difficulties with|
|Alka-Seltzer tablets.  Since there are 25~pills|↑↑{Alka-Seltzer}↑↑{ties}
|per bottle, while the manufacturer's directions|
|recommend ``plop,~plop, fizz,~fizz,'' my colleagues|
|tell me that you have accumulated a substantial|
|number of bottles in which there is one tablet|
|left. % (See the 1978 SCRIBE User Manual, page 90.)|↑↑{Scribe}
\bigskip
|At present I am engaged in research on the potential|
|applications of isolated analgesics. If you would|
|be so kind as to donate your Alka-Seltzer collection|
|to our project, I would be more than happy to send|
|you preprints of any progress reports that we may|
|publish concerning this critical problem.|
\bigskip
|\closing|
|Sincerely,|
|R. J. Drofnats|↑↑{Drofnats}
|Professor|
\bigskip
|\annotations|
|RJD/dek|
|cc: {\sl The \TeX book}|
\bigskip
|\ps|
|P. S. \ If you like, I will check into the|
|possibility that your donation and the meals that|
|you have been eating might be tax-deductible, in|↑↑{IRS}
|connection with our research.|
|\endletter|
|\makelabel|
\eject\endgroup
\def\proofcopy(#1){\ifproofmode\raise.5in\hbox{\sevenrm(#1)}\else\hfil\fi}
\vglue-\topskip \nointerlineskip
\dimen0=\vsize \advance\dimen0 by-1.2pt \advance\dimen0 by-2.1in
\vbox{\hrule
  \hbox{\vrule height \dimen0
    \hbox to 4.25in{\hss\proofcopy(Output page goes here, reduced 50\%.)\hss}
    \vrule}}
\nointerlineskip
\hrule
\line{\vrule height 2.1in
  \hss\proofcopy(Label and stamp go here, reduced 50\%.)\hss\vrule}
\hrule
\vskip 0pt plus .001pt minus .001pt % in case of rounding errors
\eject
If the letter is more than one page long, the addressee, date, and
page number will appear at the top of subsequent pages. For example,
the previous letter comes out as follows, if additional paragraphs are
added to the text:
\medskip
\hrule
\line{\vrule height 3.1127in
  \hfil\proofcopy(First page, reduced to 28.3\%.)\hfil\vrule\hfil
  \proofcopy(Second page, reduced to 28.3\%.)\hfil\vrule}
\hrule
\bigskip
\ninepoint
The macro package |letterformat.tex| that produces this format begins
with a simple macro that expands to the current ↑{date}.
\def\today{\ifcase\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space\number\day, \number\year}

\raggedbottom
\interlinepenalty=1000
\hsize=6.25truein
\voffset=24pt
\advance\vsize by-\voffset
\parindent=0pt
\parskip=0pt
\nopagenumbers
\headline={\ifnum\pageno>1
  \tenrm To \addressee\hfil\today\hfil Page \folio
  \else\hfil\fi}

\def\beginlinemode{\endmode
  \begingroup\obeylines\def\endmode{\par\endgroup}}
\def\beginparmode{\endmode
  \begingroup\parskip=\medskipamount \def\endmode{\par\endgroup}}
\let\endmode=\par
\def\endletter{\endmode\vfill\supereject}

\newdimen\longindentation \longindentation=4true in
\newbox\theaddress
\def\address{\beginlinemode\getaddress}
{\obeylines\gdef\getaddress #1
  #2
  {#1\gdef\addressee{#2}%
    \global\setbox\theaddress=\vbox\bgroup\raggedright%
    \hsize=\longindentation \everypar{\hangindent 2em}#2
    \def\endmode{\egroup\endgroup \copy\theaddress \bigskip}}}

\def\body{\beginparmode}
\def\closing{\beginlinemode\getclosing}
{\obeylines\gdef\getclosing #1
  #2
  {#1\nobreak\bigskip \leftskip=\longindentation #2
    \nobreak\bigskip\bigskip\bigskip % space for signature
    \def
    {\endgraf\nobreak}}}
\def\annotations{\beginlinemode\def\par{\endgraf\nobreak}\obeylines\par}
\def\ps{\beginparmode\nobreak
  \interlinepenalty5000\def\par{\endgraf\penalty5000}}

\def\up#1{\leavevmode \raise.16ex\hbox{#1}}
\font\smallheadfont=cmr8 at 8truept
\font\largeheadfont=cmdunh10 at 14.4truept
\font\logofont=manfnt at 14.4truept

\def\rjdletterhead{
  \def\sendingaddress{R. J. DROFNATS, F.T.U.G.\par{TeX Users Group}
    PROFESSOR OF FARM ECOLOGY\par
|    TEX.RJD @ SU-SCORE.ARPA\par|{atsign}
|    \up[415\up]\thinspace 497-4975\par}|
|  \def\returnaddress{R. J. Drofnats, Dept.~of Farm Ecology\par|
|    The University of St.~Anford\par|
|    P. O. Box 1009, Haga Alto, CA 94321 USA}|
|  \letterhead}|

|\def\letterhead{\pageno=1 \def\addressee{} \univletterhead|
|  {\leftskip=\longindentation|
|    {\baselineskip9truept\smallheadfont\sendingaddress}|
|    \bigskip\bigskip\rm\today\bigskip}}|

|\def\univletterhead{\vglue-\voffset|
|  \hbox{\hbox to\longindentation{\raise4truemm\hbox{\logofont|
|        \kern2truept X\kern-1.667truept|
|        \lower2truept\hbox{X}\kern-1.667truept X}\hfil|
|      \largeheadfont The University of St.~Anford\hfil}%|
|    \kern-\longindentation|
|    \vbox{\smallheadfont\baselineskip9truept|
|      \leftskip=\longindentation BOX 1009\par HAGA ALTO, CA 94321}}|
|  \vskip2truept\hrule\vskip4truept }|

|\def||\makelabel||{\endletter\hbox{\vrule|
|    \vbox{\hrule \kern6truept|
|      \hbox{\kern6truept\vbox to 2truein{\hsize=\longindentation|
|          \smallheadfont\baselineskip9truept\returnaddress|
|          \vfill\moveright 2truein\copy\theaddress\vfill}%|
|        \kern6truept}\kern6truept\hrule}\vrule}|
|  \pageno=0\vfill\eject}|